{% extends 'base.html' %}
{% block content %}
<h2>单张卡到期提醒</h2>
<table class="table table-bordered align-middle mb-0">
    <thead class="table-light">
        <tr>
            <th>卡号</th>
            <th>到期时间</th>
            <th>客户</th>
            <th>备注</th>
        </tr>
    </thead>
    <tbody>
        {% for reminder in page_obj %}
        <tr>
            <td>{{ reminder.card.iccid }}</td>
            <td>{{ reminder.expire_date }}</td>
            <td>
                {% with rel=reminder.card.carduserrelation_set.first %}
                    {% if rel %}{{ rel.customer.username }}{% else %}无{% endif %}
                {% endwith %}
            </td>
            <td>{{ reminder.remark }}</td>
        </tr>
        {% empty %}
        <tr><td colspan="4" class="text-center">暂无到期提醒</td></tr>
        {% endfor %}
    </tbody>
</table>
<!-- 分页控件 -->
<nav aria-label="Page navigation">
  <ul class="pagination">
    {% if page_obj.has_previous %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">上一页</a></li>
    {% else %}
      <li class="page-item disabled"><span class="page-link">上一页</span></li>
    {% endif %}
    {% for num in page_obj.paginator.page_range %}
      {% if page_obj.number == num %}
        <li class="page-item active"><span class="page-link">{{ num }}</span></li>
      {% else %}
        <li class="page-item"><a class="page-link" href="?page={{ num }}">{{ num }}</a></li>
      {% endif %}
    {% endfor %}
    {% if page_obj.has_next %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">下一页</a></li>
    {% else %}
      <li class="page-item disabled"><span class="page-link">下一页</span></li>
    {% endif %}
  </ul>
</nav>
{% endblock %}
